﻿using LogionDemo.Common.Interfaces;

namespace LogionDemo.Controls.Base.UserControls
{
	public abstract class AuditBaseUC<T> : UserControl, ISimplePublishe<T>
	{
		private readonly List<ISimpleSubscriber<T>> _subscribers = new List<ISimpleSubscriber<T>>();

		public void Publish(T args)
		{
			foreach (var subscriber in _subscribers) { subscriber.OnNext(args); }
		}

		public void Subscribe(ISimpleSubscriber<T> subscriber)
		{
			_subscribers.Add(subscriber);
		}

		public void Unsubscribe(ISimpleSubscriber<T> subscriber)
		{
			_subscribers.Remove(subscriber);
		}
	}
}